package cn.tedu.csmall.product.mapper;

import cn.tedu.csmall.product.pojo.entity.Category;
import cn.tedu.csmall.product.pojo.vo.CategoryListitemVO;
import cn.tedu.csmall.product.pojo.vo.CategoryStandardVO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;

@SpringBootTest
public class CategoryMapperTets {
   @Autowired
   CategoryMapper mapper;
   @Test
    void testInsert(){
       Category category=new Category();
       category.setName("家具");
       category.setKeywords("沙发,茶基");
       int row=mapper.insert(category);
   }
@Test
void testInserts(){
    List<Category>list=new ArrayList<>();
       Category category=new Category();
    for (int i=0; i<5; i++) {
        category.setName("家具");
        category.setKeywords("沙发,茶基");
        list.add(category);
    }
        int inserts = mapper.inserts(list);
        System.out.println(inserts);
}
   @Test
   void testdeleteById(){
         Long id=10L;
         int row=mapper.deleteById(id);
   }
   @Test
    void testdeleteByIds(){
       Long [] id={1L,2L,3L,4L,5L,6L,7L,8L,9L};
       int row=mapper.deleteByIds(id);
       System.out.println(row);
   }
   @Test
    void update(){
       Category category=new Category();
       category.setId(11L);
       category.setName("家电");
      category.setKeywords("家电,空调,洗衣机,热水器");
       int update = mapper.update(category);
   }
   @Test
    void a(){
       int row=mapper.count();
       System.out.println(row);
   }
    @Test
    void getCategory(){
       Long id=11L;
        CategoryStandardVO category = mapper.getCategory(id);
        System.out.println(category);
    }
    @Test
    void TestList(){
        List<CategoryListitemVO> list = mapper.list();
        for (CategoryListitemVO c:list) {
            System.out.println(c);
        }
    }
}
